package com.holly.unit.deform.api.pojo.component;

import com.holly.unit.system.api.pojo.organization.HrOrganizationDTO;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
 * 类描述: 组织机构树结构数据的实体类
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/4/16 11:30
 */
public class DeformDeptTreeDTO implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 对应SysDepart中的id字段,前端数据树中的key*/
    private String key;

    /** 对应SysDepart中的id字段,前端数据树中的value*/
    private String value;

    /** 对应depart_name字段,前端数据树中的title*/
    private String title;


    private boolean isLeaf;
    // 以下所有字段均与SysDepart相同

    /**
     * 主键
     */
    private Long orgId;

    /**
     * 父id，一级节点父id是0
     */
    private Long orgParentId;

    /**
     * 父ids
     */
    private String orgPids;

    /**
     * 组织名称
     */
    private String orgName;

    /**
     * 组织编码
     */
    private String orgCode;

    /**
     * 排序
     */
    private BigDecimal orgSort;

    /**
     * 状态：1-启用，2-禁用
     */
    private Integer statusFlag;

    /**
     * 组织机构描述
     */
    private String orgRemark;

    /**
     * 删除标记（Y-已删除，N-未删除）
     */
    private String delFlag;

    private List<DeformDeptTreeDTO> children = new ArrayList<>();


    /**
     * 将SysDepart对象转换成SysDepartTreeModel对象
     * @param organizationDTO
     */
    public DeformDeptTreeDTO(HrOrganizationDTO organizationDTO) {
        this.key = organizationDTO.getOrgId().toString();
        this.value = organizationDTO.getOrgId().toString();
        this.title = organizationDTO.getOrgName();
        this.orgId = organizationDTO.getOrgId();
        this.orgParentId = organizationDTO.getOrgParentId();
        this.orgPids = organizationDTO.getOrgPids();
        this.orgName = organizationDTO.getOrgName();
        this.orgCode = organizationDTO.getOrgCode();
        this.orgSort = organizationDTO.getOrgSort();
        this.statusFlag = organizationDTO.getStatusFlag();
        this.orgRemark = organizationDTO.getOrgRemark();
        this.delFlag = organizationDTO.getDelFlag();
    }
    public DeformDeptTreeDTO() { }


    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean getIsLeaf() {
        return isLeaf;
    }

    public void setIsLeaf(boolean isleaf) {
        this.isLeaf = isleaf;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Long getOrgParentId() {
        return orgParentId;
    }

    public void setOrgParentId(Long orgParentId) {
        this.orgParentId = orgParentId;
    }

    public String getOrgPids() {
        return orgPids;
    }

    public void setOrgPids(String orgPids) {
        this.orgPids = orgPids;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public String getOrgCode() {
        return orgCode;
    }

    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

    public BigDecimal getOrgSort() {
        return orgSort;
    }

    public void setOrgSort(BigDecimal orgSort) {
        this.orgSort = orgSort;
    }

    public Integer getStatusFlag() {
        return statusFlag;
    }

    public void setStatusFlag(Integer statusFlag) {
        this.statusFlag = statusFlag;
    }

    public String getOrgRemark() {
        return orgRemark;
    }

    public void setOrgRemark(String orgRemark) {
        this.orgRemark = orgRemark;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public List<DeformDeptTreeDTO> getChildren() {
        return children;
    }

    public void setChildren(List<DeformDeptTreeDTO> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }
}
